package com.marquee.friends;


import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;

import com.marquee.R;
import com.marquee.R.id;
import com.marquee.R.layout;
import com.marquee.customview.MyFragment;

public class Frag_Friends extends MyFragment implements OnClickListener {

	View view;
	
	RelativeLayout RL_FRIEND_TAB_ITEM_01,RL_FRIEND_TAB_ITEM_02,RL_FRIEND_TAB_ITEM_03;
	
    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
            Bundle savedInstanceState) {
    	
    	view = (RelativeLayout) inflater.inflate(R.layout.friends_fragment, container, false);
    	
    	
    	initTab();
    	
    	Fragment frag=null;
    	frag = new Frag_Friends_My();
    	getFragmentManager().beginTransaction()
		.replace(R.id.LL_Friend_Content, frag).commit();
    	RL_FRIEND_TAB_ITEM_01.setSelected(true);
    	
    	
        return view;
    }

	private void initTab() {
		RL_FRIEND_TAB_ITEM_01 = (RelativeLayout)view.findViewById(R.id.RL_FRIEND_TAB_ITEM_01);
    	RL_FRIEND_TAB_ITEM_02 = (RelativeLayout)view.findViewById(R.id.RL_FRIEND_TAB_ITEM_02);
    	RL_FRIEND_TAB_ITEM_03 = (RelativeLayout)view.findViewById(R.id.RL_FRIEND_TAB_ITEM_03);
    	
    	RL_FRIEND_TAB_ITEM_01.setOnClickListener(this);
    	RL_FRIEND_TAB_ITEM_02.setOnClickListener(this);
    	RL_FRIEND_TAB_ITEM_03.setOnClickListener(this);
		
	}

	@Override
	public void onClick(View v) {
		
		Fragment frag=null;
		
		switch(v.getId()){
		case R.id.RL_FRIEND_TAB_ITEM_01:
			//frag = new Frag_Test1();
			frag = new Frag_Friends_My();
			RL_FRIEND_TAB_ITEM_01.setSelected(true);
			RL_FRIEND_TAB_ITEM_02.setSelected(false);
			RL_FRIEND_TAB_ITEM_03.setSelected(false);
			break;
		case R.id.RL_FRIEND_TAB_ITEM_02:
			frag = new Frag_Friends_Add();
			RL_FRIEND_TAB_ITEM_01.setSelected(false);
			RL_FRIEND_TAB_ITEM_02.setSelected(true);
			RL_FRIEND_TAB_ITEM_03.setSelected(false);
			
			break;
		case R.id.RL_FRIEND_TAB_ITEM_03:
			frag = new Frag_Friends_Request();
			RL_FRIEND_TAB_ITEM_01.setSelected(false);
			RL_FRIEND_TAB_ITEM_02.setSelected(false);
			RL_FRIEND_TAB_ITEM_03.setSelected(true);
			break;
		
		}
		if(frag!=null){
			
			getFragmentManager().beginTransaction()
		.replace(R.id.LL_Friend_Content, frag).commit();
		}
		
	}
}

